Skip to content

Commit fba69be

Browse files
committed
URL PATH of Actions - Controller Methods Refactoring
1 parent f5c04df commit fba69be

31 files changed

+429
-799
lines changed

etc/serialversions/getserialversionid.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ serialver org.woehlke.simpleworklist.taskstate.TaskState >> ..\..\etc\serialvers
2121
serialver org.woehlke.simpleworklist.task.TaskTime >> ..\..\etc\serialversions.txt
2222
serialver org.woehlke.simpleworklist.user.resetpassword.UserPasswordRecoveryStatus >> ..\..\etc\serialversions.txt
2323
serialver org.woehlke.simpleworklist.user.register.UserRegistrationStatus >> ..\..\etc\serialversions.txt
24-
serialver org.woehlke.simpleworklist.user.UserRole >> ..\..\etc\serialversions.txt
24+
serialver org.woehlke.simpleworklist.user.account.UserRole >> ..\..\etc\serialversions.txt
2525
serialver org.woehlke.simpleworklist.common.AuditModel >> ..\..\etc\serialversions.txt
2626
serialver org.woehlke.simpleworklist.context.Context >> ..\..\etc\serialversions.txt
2727
serialver org.woehlke.simpleworklist.project.Project >> ..\..\etc\serialversions.txt
@@ -34,7 +34,7 @@ serialver org.woehlke.simpleworklist.breadcrumb.BreadcrumbItem >> ..\..\etc\ser
3434
serialver org.woehlke.simpleworklist.breadcrumb.Breadcrumb >> ..\..\etc\serialversions.txt
3535
serialver org.woehlke.simpleworklist.user.login.LoginForm >> ..\..\etc\serialversions.txt
3636
serialver org.woehlke.simpleworklist.context.NewContextForm >> ..\..\etc\serialversions.txt
37-
serialver org.woehlke.simpleworklist.user.messages.NewUser2UserMessage >> ..\..\etc\serialversions.txt
37+
serialver org.woehlke.simpleworklist.user.messages.User2UserMessageFormBean >> ..\..\etc\serialversions.txt
3838
serialver org.woehlke.simpleworklist.search.SearchResult >> ..\..\etc\serialversions.txt
3939
serialver org.woehlke.simpleworklist.user.account.UserAccountForm >> ..\..\etc\serialversions.txt
4040
serialver org.woehlke.simpleworklist.context.UserChangeDefaultContextForm >> ..\..\etc\serialversions.txt

etc/serialversions/getserialversionid.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ serialver org.woehlke.simpleworklist.taskstate.TaskState >> $SERIALVERSIONS_FILE
3333
serialver org.woehlke.simpleworklist.task.TaskTime >> $SERIALVERSIONS_FILE
3434
serialver org.woehlke.simpleworklist.user.resetpassword.UserPasswordRecoveryStatus >> $SERIALVERSIONS_FILE
3535
serialver org.woehlke.simpleworklist.user.register.UserRegistrationStatus >> $SERIALVERSIONS_FILE
36-
serialver org.woehlke.simpleworklist.user.UserRole >> $SERIALVERSIONS_FILE
36+
serialver org.woehlke.simpleworklist.user.account.UserRole >> $SERIALVERSIONS_FILE
3737
serialver org.woehlke.simpleworklist.common.AuditModel >> $SERIALVERSIONS_FILE
3838
serialver org.woehlke.simpleworklist.context.Context >> $SERIALVERSIONS_FILE
3939
serialver org.woehlke.simpleworklist.project.Project >> $SERIALVERSIONS_FILE
@@ -46,7 +46,7 @@ serialver org.woehlke.simpleworklist.breadcrumb.BreadcrumbItem >> $SERIALVERSIO
4646
serialver org.woehlke.simpleworklist.breadcrumb.Breadcrumb >> $SERIALVERSIONS_FILE
4747
serialver org.woehlke.simpleworklist.user.login.LoginForm >> $SERIALVERSIONS_FILE
4848
serialver org.woehlke.simpleworklist.context.NewContextForm >> $SERIALVERSIONS_FILE
49-
serialver org.woehlke.simpleworklist.user.messages.NewUser2UserMessage >> $SERIALVERSIONS_FILE
49+
serialver org.woehlke.simpleworklist.user.messages.User2UserMessageFormBean >> $SERIALVERSIONS_FILE
5050
serialver org.woehlke.simpleworklist.search.SearchResult >> $SERIALVERSIONS_FILE
5151
serialver org.woehlke.simpleworklist.user.account.UserAccountForm >> $SERIALVERSIONS_FILE
5252
serialver org.woehlke.simpleworklist.context.UserChangeDefaultContextForm >> $SERIALVERSIONS_FILE

etc/serialversions/serialversions.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ org.woehlke.simpleworklist.taskstate.TaskState: private static final long ser
44
org.woehlke.simpleworklist.task.TaskTime: private static final long serialVersionUID = 0L;
55
org.woehlke.simpleworklist.user.resetpassword.UserPasswordRecoveryStatus: private static final long serialVersionUID = 0L;
66
org.woehlke.simpleworklist.user.register.UserRegistrationStatus: private static final long serialVersionUID = 0L;
7-
org.woehlke.simpleworklist.user.UserRole: private static final long serialVersionUID = 0L;
7+
org.woehlke.simpleworklist.user.account.UserRole: private static final long serialVersionUID = 0L;
88
org.woehlke.simpleworklist.common.AuditModel: private static final long serialVersionUID = 4399373914714726911L;
99
org.woehlke.simpleworklist.context.Context: private static final long serialVersionUID = -5035732370606951871L;
1010
org.woehlke.simpleworklist.project.Project: private static final long serialVersionUID = 4566653175832872422L;
@@ -17,7 +17,7 @@ org.woehlke.simpleworklist.breadcrumb.BreadcrumbItem: private static final lo
1717
org.woehlke.simpleworklist.breadcrumb.Breadcrumb: private static final long serialVersionUID = 7932703111140692689L;
1818
org.woehlke.simpleworklist.user.login.LoginForm: private static final long serialVersionUID = 5936886560348238355L;
1919
org.woehlke.simpleworklist.context.NewContextForm: private static final long serialVersionUID = -937143305653156981L;
20-
org.woehlke.simpleworklist.user.messages.NewUser2UserMessage: private static final long serialVersionUID = 1576610181966480168L;
20+
org.woehlke.simpleworklist.user.messages.User2UserMessageFormBean: private static final long serialVersionUID = 1576610181966480168L;
2121
org.woehlke.simpleworklist.search.SearchResult: private static final long serialVersionUID = 1682809351146047764L;
2222
org.woehlke.simpleworklist.user.account.UserAccountForm: private static final long serialVersionUID = 9180383385243540190L;
2323
org.woehlke.simpleworklist.context.UserChangeDefaultContextForm: private static final long serialVersionUID = -8592295563275083292L;

src/main/java/org/woehlke/simpleworklist/taskstate/TaskStateServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.woehlke.simpleworklist.taskstate;
22

3+
import lombok.extern.slf4j.Slf4j;
34
import org.springframework.data.domain.Page;
45
import org.springframework.data.domain.Pageable;
56
import org.springframework.stereotype.Service;
@@ -14,6 +15,7 @@
1415
/**
1516
* Created by tw on 21.02.16.
1617
*/
18+
@Slf4j
1719
@Service
1820
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
1921
public class TaskStateServiceImpl implements TaskStateService {
Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
package org.woehlke.simpleworklist.user;
22

3-
import java.io.Serializable;
43
import java.util.ArrayList;
54
import java.util.Collection;
65
import java.util.List;
76

7+
import lombok.*;
88
import org.springframework.security.core.GrantedAuthority;
99
import org.springframework.security.core.authority.SimpleGrantedAuthority;
1010
import org.springframework.security.core.userdetails.UserDetails;
1111
import org.woehlke.simpleworklist.user.account.UserAccount;
1212

13-
public class UserDetailsBean implements UserDetails, Serializable {
13+
14+
@Getter
15+
@EqualsAndHashCode
16+
@ToString(exclude = {"password"})
17+
public class UserDetailsBean implements UserDetails {
1418

1519
private static final long serialVersionUID = 1L;
1620

@@ -42,68 +46,4 @@ public Collection<? extends GrantedAuthority> getAuthorities() {
4246
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
4347
return authorities;
4448
}
45-
46-
@Override
47-
public String getPassword() {
48-
return password;
49-
}
50-
51-
@Override
52-
public String getUsername() {
53-
return username;
54-
}
55-
56-
@Override
57-
public boolean isAccountNonExpired() {
58-
return accountNonExpired;
59-
}
60-
61-
@Override
62-
public boolean isAccountNonLocked() {
63-
return accountNonLocked;
64-
}
65-
66-
@Override
67-
public boolean isCredentialsNonExpired() {
68-
return credentialsNonExpired;
69-
}
70-
71-
@Override
72-
public boolean isEnabled() {
73-
return enabled;
74-
}
75-
76-
@Override
77-
public int hashCode() {
78-
final int prime = 31;
79-
int result = 1;
80-
result = prime * result
81-
+ ((password == null) ? 0 : password.hashCode());
82-
result = prime * result
83-
+ ((username == null) ? 0 : username.hashCode());
84-
return result;
85-
}
86-
87-
@Override
88-
public boolean equals(Object obj) {
89-
if (this == obj)
90-
return true;
91-
if (obj == null)
92-
return false;
93-
if (getClass() != obj.getClass())
94-
return false;
95-
UserDetailsBean other = (UserDetailsBean) obj;
96-
if (password == null) {
97-
if (other.password != null)
98-
return false;
99-
} else if (!password.equals(other.password))
100-
return false;
101-
if (username == null) {
102-
if (other.username != null)
103-
return false;
104-
} else if (!username.equals(other.username))
105-
return false;
106-
return true;
107-
}
108-
10949
}
Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
package org.woehlke.simpleworklist.user;
22

3+
import lombok.EqualsAndHashCode;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
import lombok.ToString;
37
import org.woehlke.simpleworklist.taskstate.TaskState;
48

59
import java.io.Serializable;
6-
import java.util.Objects;
710

811
/**
912
* Created by tw on 13.03.16.
1013
*/
14+
@Getter
15+
@Setter
16+
@EqualsAndHashCode
17+
@ToString
1118
public class UserSessionBean implements Serializable {
1219

1320
private static final long serialVersionUID = -6649686058228455825L;
1421

1522
private Long contextId;
16-
17-
private String lastSearchterm;
18-
1923
private TaskState lastTaskState;
20-
2124
private Long lastProjectId;
25+
private String lastSearchterm;
2226

2327
public UserSessionBean(){
2428
lastSearchterm="";
@@ -34,61 +38,4 @@ public UserSessionBean(long contextId){
3438
this.contextId = contextId;
3539
}
3640

37-
public Long getContextId() {
38-
return contextId;
39-
}
40-
41-
public void setContextId(Long contextId) {
42-
this.contextId = contextId;
43-
}
44-
45-
public String getLastSearchterm() {
46-
return lastSearchterm;
47-
}
48-
49-
public void setLastSearchterm(String lastSearchterm) {
50-
this.lastSearchterm = lastSearchterm;
51-
}
52-
53-
public TaskState getLastTaskState() {
54-
return lastTaskState;
55-
}
56-
57-
public void setLastTaskState(TaskState lastTaskState) {
58-
this.lastTaskState = lastTaskState;
59-
}
60-
61-
public Long getLastProjectId() {
62-
return lastProjectId;
63-
}
64-
65-
public void setLastProjectId(Long lastProjectId) {
66-
this.lastProjectId = lastProjectId;
67-
}
68-
69-
@Override
70-
public boolean equals(Object o) {
71-
if (this == o) return true;
72-
if (!(o instanceof UserSessionBean)) return false;
73-
UserSessionBean that = (UserSessionBean) o;
74-
return getContextId().equals(that.getContextId()) &&
75-
getLastSearchterm().equals(that.getLastSearchterm()) &&
76-
getLastTaskState() == that.getLastTaskState() &&
77-
getLastProjectId().equals(that.getLastProjectId());
78-
}
79-
80-
@Override
81-
public int hashCode() {
82-
return Objects.hash(getContextId(), getLastSearchterm(), getLastTaskState(), getLastProjectId());
83-
}
84-
85-
@Override
86-
public String toString() {
87-
return "UserSessionBean{" +
88-
"contextId=" + contextId +
89-
", lastSearchterm='" + lastSearchterm + '\'' +
90-
", lastTaskState=" + lastTaskState +
91-
", lastProjectId=" + lastProjectId +
92-
'}';
93-
}
9441
}
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.woehlke.simpleworklist.user.account;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
3+
import lombok.extern.slf4j.Slf4j;
54
import org.springframework.beans.factory.annotation.Autowired;
65
import org.springframework.security.authentication.AuthenticationManager;
76
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -14,31 +13,38 @@
1413
import org.woehlke.simpleworklist.user.login.LoginForm;
1514
import org.woehlke.simpleworklist.user.selfservice.UserChangePasswordForm;
1615

16+
@Slf4j
1717
@Service
1818
@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
1919
public class UserAccountAccessServiceImpl implements UserAccountAccessService {
2020

21-
private static final Logger LOGGER = LoggerFactory.getLogger(UserAccountAccessServiceImpl.class);
22-
2321
private final UserAccountRepository userAccountRepository;
24-
2522
private final AuthenticationManager authenticationManager;
26-
2723
private final PasswordEncoder encoder;
2824

2925
@Autowired
30-
public UserAccountAccessServiceImpl(UserAccountRepository userAccountRepository, AuthenticationManager authenticationManager) {
26+
public UserAccountAccessServiceImpl(
27+
UserAccountRepository userAccountRepository,
28+
AuthenticationManager authenticationManager
29+
) {
3130
this.userAccountRepository = userAccountRepository;
3231
this.authenticationManager = authenticationManager;
32+
//TODO:
3333
int strength = 10;
3434
this.encoder = new BCryptPasswordEncoder(strength);
3535
}
3636

3737

3838
@Override
3939
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
40-
public void changeUsersPassword(UserChangePasswordForm userAccountFormBean, UserAccount user) {
41-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUserEmail(), userAccountFormBean.getOldUserPassword());
40+
public void changeUsersPassword(
41+
UserChangePasswordForm userAccountFormBean,
42+
UserAccount user
43+
) {
44+
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
45+
user.getUserEmail(),
46+
userAccountFormBean.getOldUserPassword()
47+
);
4248
Authentication authenticationResult = authenticationManager.authenticate(token);
4349
if(authenticationResult.isAuthenticated()){
4450
UserAccount ua = userAccountRepository.findByUserEmail(user.getUserEmail());
@@ -49,17 +55,26 @@ public void changeUsersPassword(UserChangePasswordForm userAccountFormBean, User
4955
}
5056

5157
@Override
52-
public boolean confirmUserByLoginAndPassword(String userEmail, String oldUserPassword) {
53-
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userEmail, oldUserPassword);
58+
public boolean confirmUserByLoginAndPassword(
59+
String userEmail,
60+
String oldUserPassword
61+
) {
62+
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
63+
userEmail,
64+
oldUserPassword
65+
);
5466
Authentication authenticationResult = authenticationManager.authenticate(token);
5567
String oldPwEncoded = this.encoder.encode(oldUserPassword);
56-
LOGGER.info(userEmail+", "+oldPwEncoded);
68+
log.info(userEmail+", "+oldPwEncoded);
5769
return authenticationResult.isAuthenticated();
5870
}
5971

6072
@Override
6173
public boolean authorize(LoginForm loginForm) {
62-
UserAccount account = userAccountRepository.findByUserEmailAndUserPassword(loginForm.getUserEmail(), loginForm.getUserPassword());
74+
UserAccount account = userAccountRepository.findByUserEmailAndUserPassword(
75+
loginForm.getUserEmail(),
76+
loginForm.getUserPassword()
77+
);
6378
return account != null;
6479
}
6580
}

0 commit comments

Comments
 (0)