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;
43 * Value of the tool bar property.
44 * It can be: none, standard, study, back.
46 private String _toolProperty;
48 // ==============================================================================================================================
50 // ==============================================================================================================================
52 public String doImport () {
54 User user = getConnectedUser(); // The database administrator
55 File updir = getRepositoryService().getDownloadDirectory(user);
56 File upfile = new File(updir.getPath() + "/" + filename);
58 newsers = getUserService().importUsers(upfile);
59 users = getUserService().selectAllUsers();
60 for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
62 if (!next.equals(user)) continue;
63 i.remove(); // Just for not showing the corresponding reserved username
67 setMenuProperty("sysadmin");
68 setToolProperty("none");
69 initializationScreenContext(_menuProperty, _toolProperty);
73 catch (Exception error) {
78 // ==============================================================================================================================
80 // ==============================================================================================================================
82 public List<User> getUsers () {
83 // -----------------------------
87 public boolean isNew (User user) {
88 // --------------------------------
89 return newsers.contains(user);
93 * Get the repositoryService.
94 * @return the repositoryService
96 public RepositoryService getRepositoryService() {
97 return _repositoryService;
101 * Set the repositoryService.
102 * @param repositoryService the repositoryService to set
104 public void setRepositoryService(RepositoryService repositoryService) {
105 _repositoryService = repositoryService;
109 * Get the userService.
110 * @return the userService
112 public UserService getUserService() {
117 * Set the userService.
118 * @param userService the userService to set
120 public void setUserService(UserService userService) {
121 _userService = userService;
125 * Get the menuProperty.
126 * @return the menuProperty
128 public String getMenuProperty() {
129 return _menuProperty;
133 * Set the menuProperty.
134 * @param menuProperty the menuProperty to set
136 public void setMenuProperty(String menuProperty) {
137 this._menuProperty = menuProperty;
141 * Get the toolProperty.
142 * @return the toolProperty
144 public String getToolProperty() {
145 return _toolProperty;
149 * Set the toolProperty.
150 * @param toolProperty the toolProperty to set
152 public void setToolProperty(final String toolProperty) {
153 _toolProperty = toolProperty;