mirror of https://github.com/apache/jclouds.git
Merge pull request #1375 from maginatics/blob-builder-null-or-empty-name
Prohibit null and empty blob names in BlobBuilder
This commit is contained in:
commit
e16c7ba40c
|
@ -18,7 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.domain.internal;
|
package org.jclouds.blobstore.domain.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static org.jclouds.io.Payloads.newPayload;
|
import static org.jclouds.io.Payloads.newPayload;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -48,6 +50,8 @@ public class BlobBuilderImpl implements BlobBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlobBuilder name(String name) {
|
public BlobBuilder name(String name) {
|
||||||
|
checkNotNull(name, "name");
|
||||||
|
checkArgument(!name.isEmpty(), "name");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -106,8 +110,8 @@ public class BlobBuilderImpl implements BlobBuilder {
|
||||||
@Override
|
@Override
|
||||||
public Blob build() {
|
public Blob build() {
|
||||||
Blob blob = new BlobImpl(new MutableBlobMetadataImpl());
|
Blob blob = new BlobImpl(new MutableBlobMetadataImpl());
|
||||||
if (name != null)
|
checkState(name != null, "name");
|
||||||
blob.getMetadata().setName(name);
|
blob.getMetadata().setName(name);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
blob.setPayload(payload);
|
blob.setPayload(payload);
|
||||||
blob.getMetadata().setUserMetadata(userMetadata);
|
blob.getMetadata().setUserMetadata(userMetadata);
|
||||||
|
|
Loading…
Reference in New Issue