Skip to content
Permalink
Browse files
[JENKINS-36432 followup] Address some review comments
  • Loading branch information
stephenc committed Sep 23, 2016
1 parent 3f08ccc commit 505f4e4ca6cd7fc69cb5ad0ca16499c8bf390f96
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/main/java/org/jenkinsci/plugins/plaincredentials/impl/FileCredentialsImpl.java
@@ -93,7 +93,7 @@ public final class FileCredentialsImpl extends BaseStandardCredentials implement
* @param description the description of the credentials.
* @param file the uploaded file.
* @param fileName the name of the file.
* @param secretBytes the content of the file.
* @param data the content of the file.
* @throws IOException when things go wrong.
* @deprecated use {@link #FileCredentialsImpl(CredentialsScope, String, String, FileItem, String, SecretBytes)} for
* stapler or {@link #FileCredentialsImpl(CredentialsScope, String, String, String, SecretBytes)} for programatic
@@ -102,15 +102,15 @@ public final class FileCredentialsImpl extends BaseStandardCredentials implement
@Deprecated
public FileCredentialsImpl(@CheckForNull CredentialsScope scope, @CheckForNull String id,
@CheckForNull String description, @Nonnull FileItem file, @CheckForNull String fileName,
@CheckForNull String secretBytes) throws IOException {
@CheckForNull String data) throws IOException {
super(scope, id, description);
String name = file.getName();
if (name.length() > 0) {
this.fileName = name.replaceFirst("^.+[/\\\\]", "");
this.secretBytes = SecretBytes.fromBytes(file.get());
} else {
this.fileName = fileName;
this.secretBytes = SecretBytes.fromString(secretBytes);
this.secretBytes = SecretBytes.fromString(data);
}
if (this.fileName == null || this.fileName.isEmpty()) {
throw new IllegalArgumentException(
@@ -145,6 +145,9 @@ public FileCredentialsImpl(@CheckForNull CredentialsScope scope, @CheckForNull S
this.fileName = name.replaceFirst("^.+[/\\\\]", "");
this.secretBytes = SecretBytes.fromBytes(file.get());
} else {
if (secretBytes == null) {
throw new IllegalArgumentException("No content provided or resolved.");
}
this.fileName = fileName;
this.secretBytes = secretBytes;
}

0 comments on commit 505f4e4

Please sign in to comment.