small cleanup
This commit is contained in:
parent
29fb3263c9
commit
7724bd2428
|
@ -42,7 +42,7 @@ public class User {
|
|||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
public void setUsername(final String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class User {
|
|||
return accessToken;
|
||||
}
|
||||
|
||||
public void setAccessToken(String accessToken) {
|
||||
public void setAccessToken(final String accessToken) {
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class User {
|
|||
return refreshToken;
|
||||
}
|
||||
|
||||
public void setRefreshToken(String refreshToken) {
|
||||
public void setRefreshToken(final String refreshToken) {
|
||||
this.refreshToken = refreshToken;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class User {
|
|||
return tokenExpiration;
|
||||
}
|
||||
|
||||
public void setTokenExpiration(Date tokenExpiration) {
|
||||
public void setTokenExpiration(final Date tokenExpiration) {
|
||||
this.tokenExpiration = tokenExpiration;
|
||||
}
|
||||
|
||||
|
@ -74,10 +74,12 @@ public class User {
|
|||
return needCaptcha;
|
||||
}
|
||||
|
||||
public void setNeedCaptcha(boolean needCaptcha) {
|
||||
public void setNeedCaptcha(final boolean needCaptcha) {
|
||||
this.needCaptcha = needCaptcha;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
@ -108,4 +110,5 @@ public class User {
|
|||
public String toString() {
|
||||
return "User [username=" + username + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,6 @@ import org.baeldung.reddit.util.RedditApiConstants;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
|
@ -24,7 +23,6 @@ import org.springframework.util.MultiValueMap;
|
|||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@EnableScheduling
|
||||
public class ScheduledTasks {
|
||||
|
||||
private OAuth2RestTemplate redditRestTemplate;
|
||||
|
@ -42,8 +40,15 @@ public class ScheduledTasks {
|
|||
}
|
||||
}
|
||||
|
||||
private void submitPost(Post post) {
|
||||
private void submitPost(final Post post) {
|
||||
try {
|
||||
submitPostInternal(post);
|
||||
} catch (final Exception e) {
|
||||
logger.error("Error occurred while submitting post " + post.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void submitPostInternal(final Post post) {
|
||||
final User user = post.getUser();
|
||||
final DefaultOAuth2AccessToken token = new DefaultOAuth2AccessToken(user.getAccessToken());
|
||||
token.setRefreshToken(new DefaultOAuth2RefreshToken((user.getRefreshToken())));
|
||||
|
@ -78,12 +83,9 @@ public class ScheduledTasks {
|
|||
postReopsitory.save(post);
|
||||
logger.info("Error occurred: " + errorNode.toString() + "while submitting post " + post.toString());
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
logger.error("Error occurred while submitting post " + post.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRedditRestTemplate(OAuth2RestTemplate redditRestTemplate) {
|
||||
public void setRedditRestTemplate(final OAuth2RestTemplate redditRestTemplate) {
|
||||
this.redditRestTemplate = redditRestTemplate;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue