Introduce a helper method: OneDriveToken.isAssigned

This commit is contained in:
Duncan Mak 2015-12-18 13:35:50 -05:00
Родитель fc220ba7b1
Коммит 4167c83a3c
3 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -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 {