1 package fr.ifremer.reefdb.service.administration.user; 2 3 /* 4 * #%L 5 * Reef DB :: Core 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2014 - 2015 Ifremer 10 * %% 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Affero General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU Affero General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 * #L% 24 */ 25 26 import fr.ifremer.reefdb.dto.configuration.filter.person.PersonCriteriaDTO; 27 import fr.ifremer.reefdb.dto.referential.PersonDTO; 28 import fr.ifremer.reefdb.dto.referential.PrivilegeDTO; 29 import org.springframework.security.access.prepost.PreAuthorize; 30 import org.springframework.transaction.annotation.Transactional; 31 32 import java.util.Collection; 33 import java.util.List; 34 35 /** 36 * <p>UserService interface.</p> 37 * 38 */ 39 @Transactional(readOnly = true) 40 public interface UserService extends fr.ifremer.quadrige3.core.service.administration.user.UserService { 41 42 /** 43 * <p>getDepartmentIdByUserId.</p> 44 * 45 * @param userId a int. 46 * @return a {@link java.lang.Integer} object. 47 */ 48 Integer getDepartmentIdByUserId(int userId); 49 50 /** 51 * <p>isLoginExtranet.</p> 52 * 53 * @param login a {@link java.lang.String} object. 54 * @return a {@link java.lang.Boolean} object. 55 */ 56 Boolean isLoginExtranet(String login); 57 58 /** 59 * User has not password define ? 60 * 61 * @param login a {@link java.lang.String} object. 62 * @return a boolean. 63 */ 64 boolean hasPassword(String login); 65 66 /** 67 * Is user a local user with an empty password ? 68 * 69 * @param login a {@link java.lang.String} object. 70 * @return a boolean. 71 */ 72 boolean isLocalUserWithNoPassword(String login); 73 74 /** 75 * <p>updatePasswordByUserId.</p> 76 * 77 * @param personId a int. 78 * @param password a {@link java.lang.String} object. 79 */ 80 @Transactional() 81 void updatePasswordByUserId(int personId, String password); 82 83 /** 84 * <p>getActiveUsers.</p> 85 * 86 * @return a {@link java.util.List} object. 87 */ 88 List<PersonDTO> getActiveUsers(); 89 90 /** 91 * <p>resetPassword.</p> 92 * 93 * @param login a {@link java.lang.String} object. 94 */ 95 @Transactional() 96 void resetPassword(String login); 97 98 /** 99 * Search User. 100 * 101 * @param searchCriteria Search parameter 102 * @return User list 103 */ 104 List<PersonDTO> searchUser(PersonCriteriaDTO searchCriteria); 105 106 /** 107 * <p>getAllPrivileges.</p> 108 * 109 * @return a {@link java.util.List} object. 110 */ 111 List<PrivilegeDTO> getAllPrivileges(); 112 113 /** 114 * <p>getAvailablePrivileges.</p> 115 * 116 * @return a {@link java.util.List} object. 117 */ 118 List<PrivilegeDTO> getAvailablePrivileges(); 119 120 /** 121 * <p>getPrivilegesByUser.</p> 122 * 123 * @param userId a {@link java.lang.Integer} object. 124 * @return a {@link java.util.Collection} object. 125 */ 126 Collection<PrivilegeDTO> getPrivilegesByUser(Integer userId); 127 128 /** 129 * <p>saveUsers.</p> 130 * 131 * @param users a {@link List} object. 132 * @return a {@link java.util.List} object. 133 */ 134 @Transactional() 135 @PreAuthorize("hasPermission(null, {T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).LOCAL_ADMIN})") 136 void saveUsers(List<PersonDTO> users); 137 138 /** 139 * <p>deleteUsers.</p> 140 * 141 * @param personIds a {@link java.util.List} object. 142 */ 143 @Transactional() 144 @PreAuthorize("hasPermission(null, {T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).LOCAL_ADMIN})") 145 void deleteUsers(List<Integer> personIds); 146 147 /** 148 * Replaces a local user by a national or local quser. 149 * All data related to this former user should be updated to use the latter 150 * 151 * @param source a {@link fr.ifremer.reefdb.dto.referential.PersonDTO} object. 152 * @param target a {@link fr.ifremer.reefdb.dto.referential.PersonDTO} object. 153 * @param delete a boolean. 154 */ 155 @Transactional() 156 @PreAuthorize("hasPermission(null, {T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).LOCAL_ADMIN})") 157 void replaceUser(PersonDTO source, PersonDTO target, boolean delete); 158 159 /** 160 * Check if a user is used (in program/strategy) or not 161 * 162 * @param userId a int. 163 * @return a boolean. 164 */ 165 boolean isUserUsedInProgram(int userId); 166 167 /** 168 * Check if a user is used (in control rules) or not 169 * 170 * @param userId a int. 171 * @return a boolean. 172 */ 173 boolean isUserUsedInRules(int userId); 174 175 /** 176 * Check if a user is used (in data) or not 177 * 178 * @param userId a int. 179 * @return a boolean. 180 */ 181 boolean isUserUsedInData(int userId); 182 183 /** 184 * <p>isUserUsedInValidatedData.</p> 185 * 186 * @param userId a int. 187 * @return a boolean. 188 */ 189 boolean isUserUsedInValidatedData(int userId); 190 }