1 package org.splat.simer.admin;
4 import java.util.Iterator;
8 import org.hibernate.Session;
9 import org.hibernate.Transaction;
10 import org.splat.dal.bo.kernel.User;
11 import org.splat.service.UserService;
12 import org.splat.service.technical.RepositoryService;
13 import org.splat.simer.UploadBaseNextAction;
14 import org.splat.dal.dao.som.Database;
17 public class ImportUserAction extends UploadBaseNextAction {
22 private static final long serialVersionUID = 1516715800624817965L;
24 private List<User> users;
25 private Set<User> newsers;
27 * Injected repository service.
29 private RepositoryService _repositoryService;
32 * Injected user service.
34 private UserService _userService;
36 // ==============================================================================================================================
38 // ==============================================================================================================================
40 public String doImport () {
41 // -------------------------
42 Session connex = Database.getCurSession();
43 Transaction transax = connex.beginTransaction();
45 User user = getConnectedUser(); // The database administrator
46 File updir = getRepositoryService().getDownloadDirectory(user);
47 File upfile = new File(updir.getPath() + "/" + filename);
49 newsers = getUserService().importUsers(upfile);
50 users = getUserService().selectAllUsers();
51 for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
53 if (!next.equals(user)) continue;
54 i.remove(); // Just for not showing the corresponding reserved username
60 catch (Exception error) {
65 // ==============================================================================================================================
67 // ==============================================================================================================================
69 public List<User> getUsers () {
70 // -----------------------------
74 public boolean isNew (User user) {
75 // --------------------------------
76 return newsers.contains(user);
80 * Get the repositoryService.
81 * @return the repositoryService
83 public RepositoryService getRepositoryService() {
84 return _repositoryService;
88 * Set the repositoryService.
89 * @param repositoryService the repositoryService to set
91 public void setRepositoryService(RepositoryService repositoryService) {
92 _repositoryService = repositoryService;
96 * Get the userService.
97 * @return the userService
99 public UserService getUserService() {
104 * Set the userService.
105 * @param userService the userService to set
107 public void setUserService(UserService userService) {
108 _userService = userService;