Introduce a helper method: OneDriveToken.isAssigned
This commit is contained in:
Родитель
fc220ba7b1
Коммит
4167c83a3c
|
@ -43,6 +43,8 @@ public interface OneDriveToken extends StandardCredentials {
|
|||
@Nonnull
|
||||
String getClientId();
|
||||
|
||||
boolean isAssigned();
|
||||
|
||||
@Nonnull
|
||||
String getClientSecret();
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ public class OneDriveClient extends BPDefaultClient<OneDriveTransfer> {
|
|||
|
||||
public boolean setClientIdAndSecret() throws IOException, OneDriveException {
|
||||
List<OneDriveToken> credentials = CredentialsProvider.lookupCredentials(OneDriveToken.class, Jenkins.getInstance(), null, (DomainRequirement) null);
|
||||
for (OneDriveToken token : credentials) {
|
||||
if (!token.getClientId().equals("") && !token.getClientSecret().equals("")) {
|
||||
Config.CLIENT_ID = token.getClientId();
|
||||
Config.CLIENT_SECRET = token.getClientSecret();
|
||||
for (OneDriveToken t : credentials) {
|
||||
if (t.isAssigned()) {
|
||||
Config.CLIENT_ID = t.getClientId();
|
||||
Config.CLIENT_SECRET = t.getClientSecret();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class OneDriveClient extends BPDefaultClient<OneDriveTransfer> {
|
|||
}
|
||||
|
||||
public boolean connect() throws OneDriveException, IOException {
|
||||
setClientIdAndSecret();
|
||||
this.setClientIdAndSecret();
|
||||
try {
|
||||
return onedrive.connect();
|
||||
} catch (IOException ioe) {
|
||||
|
|
|
@ -85,6 +85,10 @@ public class OneDriveTokenImpl extends BaseStandardCredentials implements OneDri
|
|||
return accessCode;
|
||||
}
|
||||
|
||||
public boolean isAssigned() {
|
||||
return (this.getClientId().length() > 0) && (this.getClientSecret().length() > 0);
|
||||
}
|
||||
|
||||
@Extension
|
||||
public static class DescriptorImpl extends BaseStandardCredentialsDescriptor {
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче