Sonar issues - complexity

* Fix checkstyle issue.
This commit is contained in:
Gary Russell
2019-05-03 20:05:16 -04:00
committed by Artem Bilan
parent 90d2b30066
commit 86c7e36667
32 changed files with 1024 additions and 831 deletions

View File

@@ -24,6 +24,7 @@ import javax.net.ssl.TrustManager;
import org.apache.commons.net.ftp.FTPSClient;
import org.springframework.integration.util.JavaUtils;
import org.springframework.util.StringUtils;
/**
@@ -141,37 +142,18 @@ public class DefaultFtpsSessionFactory extends AbstractFtpSessionFactory<FTPSCli
}
@Override
protected void postProcessClientBeforeConnect(FTPSClient ftpsClient) throws IOException {
if (StringUtils.hasText(this.authValue)) {
ftpsClient.setAuthValue(this.authValue);
}
if (this.trustManager != null) {
ftpsClient.setTrustManager(this.trustManager);
}
if (this.cipherSuites != null) {
ftpsClient.setEnabledCipherSuites(this.cipherSuites);
}
if (this.protocols != null) {
ftpsClient.setEnabledProtocols(this.protocols);
}
if (this.sessionCreation != null) {
ftpsClient.setEnabledSessionCreation(this.sessionCreation);
}
if (this.useClientMode != null) {
ftpsClient.setUseClientMode(this.useClientMode);
}
if (this.sessionCreation != null) {
ftpsClient.setEnabledSessionCreation(this.sessionCreation);
}
if (this.keyManager != null) {
ftpsClient.setKeyManager(this.keyManager);
}
if (this.needClientAuth != null) {
ftpsClient.setNeedClientAuth(this.needClientAuth);
}
if (this.wantsClientAuth != null) {
ftpsClient.setWantClientAuth(this.wantsClientAuth);
}
protected void postProcessClientBeforeConnect(FTPSClient ftpsClient) {
JavaUtils.INSTANCE
.acceptIfHasText(this.authValue, ftpsClient::setAuthValue)
.acceptIfNotNull(this.trustManager, ftpsClient::setTrustManager)
.acceptIfNotNull(this.cipherSuites, ftpsClient::setEnabledCipherSuites)
.acceptIfNotNull(this.protocols, ftpsClient::setEnabledProtocols)
.acceptIfNotNull(this.sessionCreation, ftpsClient::setEnabledSessionCreation)
.acceptIfNotNull(this.useClientMode, ftpsClient::setUseClientMode)
.acceptIfNotNull(this.sessionCreation, ftpsClient::setEnabledSessionCreation)
.acceptIfNotNull(this.keyManager, ftpsClient::setKeyManager)
.acceptIfNotNull(this.needClientAuth, ftpsClient::setNeedClientAuth)
.acceptIfNotNull(this.wantsClientAuth, ftpsClient::setWantClientAuth);
}
}

View File

@@ -65,72 +65,42 @@ public class FtpFileInfo extends AbstractFileInfo<FTPFile> {
@Override
public String getPermissions() {
StringBuilder sb = new StringBuilder();
if (this.ftpFile.isDirectory()) {
sb.append("d");
}
else if (this.ftpFile.isSymbolicLink()) {
sb.append("l");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)) {
sb.append("r");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)) {
sb.append("w");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
sb.append("x");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION)) {
sb.append("r");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION)) {
sb.append("w");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
sb.append("x");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION)) {
sb.append("r");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION)) {
sb.append("w");
}
else {
sb.append("-");
}
if (this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)) {
sb.append("x");
}
else {
sb.append("-");
}
appendPermissionString(sb, this.ftpFile.isDirectory(), 'd', this.ftpFile.isSymbolicLink(), 'l');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION), 'r');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION), 'w');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION), 'x');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION), 'r');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION), 'w');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION), 'x');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION), 'r');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION), 'w');
appendPermissionString(sb, this.ftpFile.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION), 'x');
return sb.toString();
}
private void appendPermissionString(StringBuilder sb, boolean condition1, char char1, boolean condition2,
char char2) {
if (condition1) {
sb.append(char1);
}
else if (condition2) {
sb.append(char2);
}
else {
sb.append('-');
}
}
private void appendPermissionString(StringBuilder sb, boolean condition, char char1) {
if (condition) {
sb.append(char1);
}
else {
sb.append('-');
}
}
@Override
public FTPFile getFileInfo() {
return this.ftpFile;