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;
49 * Value of the left menu property.
50 * It can be: open, study, knowledge, scenario.
52 private String _leftMenuProperty;
54 // ==============================================================================================================================
56 // ==============================================================================================================================
58 public String doImport () {
60 User user = getConnectedUser(); // The database administrator
61 File updir = getRepositoryService().getDownloadDirectory(user);
62 File upfile = new File(updir.getPath() + "/" + filename);
64 newsers = getUserService().importUsers(upfile);
65 users = getUserService().selectAllUsers();
66 for (Iterator<User> i=users.iterator(); i.hasNext(); ) {
68 if (!next.equals(user)) continue;
69 i.remove(); // Just for not showing the corresponding reserved username
73 setMenuProperty("sysadmin");
74 setToolProperty("none");
75 setLeftMenuProperty("open");
76 initializationFullScreenContext(_menuProperty, _toolProperty, _leftMenuProperty);
80 catch (Exception error) {
85 // ==============================================================================================================================
87 // ==============================================================================================================================
89 public List<User> getUsers () {
90 // -----------------------------
94 public boolean isNew (User user) {
95 // --------------------------------
96 return newsers.contains(user);
100 * Get the repositoryService.
101 * @return the repositoryService
103 public RepositoryService getRepositoryService() {
104 return _repositoryService;
108 * Set the repositoryService.
109 * @param repositoryService the repositoryService to set
111 public void setRepositoryService(RepositoryService repositoryService) {
112 _repositoryService = repositoryService;
116 * Get the userService.
117 * @return the userService
119 public UserService getUserService() {
124 * Set the userService.
125 * @param userService the userService to set
127 public void setUserService(UserService userService) {
128 _userService = userService;
132 * Get the menuProperty.
133 * @return the menuProperty
135 public String getMenuProperty() {
136 return _menuProperty;
140 * Set the menuProperty.
141 * @param menuProperty the menuProperty to set
143 public void setMenuProperty(String menuProperty) {
144 this._menuProperty = menuProperty;
148 * Get the toolProperty.
149 * @return the toolProperty
151 public String getToolProperty() {
152 return _toolProperty;
156 * Set the toolProperty.
157 * @param toolProperty the toolProperty to set
159 public void setToolProperty(final String toolProperty) {
160 _toolProperty = toolProperty;
164 * Get the leftMenuProperty.
165 * @return the leftMenuProperty
167 public String getLeftMenuProperty() {
168 return _leftMenuProperty;
172 * Set the leftMenuProperty.
173 * @param leftMenuProperty the leftMenuProperty to set
175 public void setLeftMenuProperty(final String leftMenuProperty) {
176 _leftMenuProperty = leftMenuProperty;