27
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
import java.sql.BatchUpdateException;
32
import org.hibernate.exception.ConstraintViolationException;
33
import org.hisp.dhis.i18n.I18n;
34
import org.hisp.dhis.i18n.I18nFormat;
30
35
import org.hisp.dhis.user.UserAuthorityGroup;
36
import org.hisp.dhis.user.UserCredentials;
31
37
import org.hisp.dhis.user.UserStore;
38
import org.springframework.dao.DataIntegrityViolationException;
33
40
import com.opensymphony.xwork2.Action;
36
43
* @author Thanh Nguyen
37
44
* @version $Id: RemoveRoleAction.java 5724 2008-09-18 14:37:01Z larshelg $
45
* @version $Id: RemoveRoleAction.java 339942 2009-12-21 10:21:03Z chauthutran $
39
public class RemoveRoleAction
42
// -------------------------------------------------------------------------
44
// -------------------------------------------------------------------------
46
private UserStore userStore;
48
public void setUserStore( UserStore userStore )
50
this.userStore = userStore;
53
// -------------------------------------------------------------------------
55
// -------------------------------------------------------------------------
59
public void setId( Integer id )
64
// -------------------------------------------------------------------------
65
// Action implementation
66
// -------------------------------------------------------------------------
68
public String execute()
71
UserAuthorityGroup authorityGroup = userStore.getUserAuthorityGroup( id );
73
if ( authorityGroup != null )
75
userStore.deleteUserAuthorityGroup( authorityGroup );
47
public class RemoveRoleAction implements Action {
48
// -------------------------------------------------------------------------
50
// -------------------------------------------------------------------------
52
private UserStore userStore;
54
public void setUserStore(UserStore userStore) {
55
this.userStore = userStore;
58
// -------------------------------------------------------------------------
60
// -------------------------------------------------------------------------
64
public void setId(Integer id) {
68
private String message;
70
public String getMessage() {
76
public void setI18n(I18n i18n) {
80
// -------------------------------------------------------------------------
81
// Action implementation
82
// -------------------------------------------------------------------------
84
public String execute() throws Exception {
86
UserAuthorityGroup authorityGroup = userStore.getUserAuthorityGroup(id);
88
if (authorityGroup != null) {
90
userStore.deleteUserAuthorityGroup(authorityGroup);
91
}catch(DataIntegrityViolationException e){
92
message = i18n.getString("user_use_group");