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;
37 * Value of the menu property.
38 * It can be: none, create, open, study, knowledge, sysadmin, help.
40 private String _menuProperty;
42 // ==============================================================================================================================
44 // ==============================================================================================================================
46 public String doImport () {
48 User user = getConnectedUser(); // The database administrator
49 File updir = getRepositoryService().getDownloadDirectory(user);
50 File upfile = new File(updir.getPath() + "/" + filename);
52 newsers = getUserService().importUsers(upfile);
53 users = getUserService().selectAllUsers();
54 for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
56 if (!next.equals(user)) continue;
57 i.remove(); // Just for not showing the corresponding reserved username
61 setMenuProperty("sysadmin");
62 initializationScreenContext(_menuProperty);
66 catch (Exception error) {
71 // ==============================================================================================================================
73 // ==============================================================================================================================
75 public List<User> getUsers () {
76 // -----------------------------
80 public boolean isNew (User user) {
81 // --------------------------------
82 return newsers.contains(user);
86 * Get the repositoryService.
87 * @return the repositoryService
89 public RepositoryService getRepositoryService() {
90 return _repositoryService;
94 * Set the repositoryService.
95 * @param repositoryService the repositoryService to set
97 public void setRepositoryService(RepositoryService repositoryService) {
98 _repositoryService = repositoryService;
102 * Get the userService.
103 * @return the userService
105 public UserService getUserService() {
110 * Set the userService.
111 * @param userService the userService to set
113 public void setUserService(UserService userService) {
114 _userService = userService;
118 * Get the menuProperty.
119 * @return the menuProperty
121 public String getMenuProperty() {
122 return _menuProperty;
126 * Set the menuProperty.
127 * @param menuProperty the menuProperty to set
129 public void setMenuProperty(String menuProperty) {
130 this._menuProperty = menuProperty;