Merge pull request #564 from harshavardhana/pr_out_rename_isvalidobject_to_isvalidobjectname_

This commit is contained in:
Harshavardhana 2015-05-01 20:33:05 -07:00
commit 600a75a786
3 changed files with 12 additions and 12 deletions

View File

@ -212,7 +212,7 @@ func (d donutDriver) GetObject(target io.Writer, bucketName, objectName string)
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil)
}
if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" {
if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" {
return 0, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil)
}
reader, size, err := d.donut.GetObject(bucketName, objectName)
@ -238,7 +238,7 @@ func (d donutDriver) GetPartialObject(w io.Writer, bucketName, objectName string
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, errParams)
}
if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" {
if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" {
return 0, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, errParams)
}
if start < 0 {
@ -282,7 +282,7 @@ func (d donutDriver) GetObjectMetadata(bucketName, objectName, prefixName string
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil)
}
if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" {
if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" {
return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil)
}
metadata, err := d.donut.GetObjectMetadata(bucketName, objectName)
@ -326,7 +326,7 @@ func (d donutDriver) ListObjects(bucketName string, resources drivers.BucketReso
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return nil, drivers.BucketResourcesMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil)
}
if !drivers.IsValidObject(resources.Prefix) {
if !drivers.IsValidObjectName(resources.Prefix) {
return nil, drivers.BucketResourcesMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: resources.Prefix}, nil)
}
actualObjects, commonPrefixes, isTruncated, err := d.donut.ListObjects(bucketName,
@ -375,7 +375,7 @@ func (d donutDriver) CreateObject(bucketName, objectName, contentType, expectedM
if !drivers.IsValidBucket(bucketName) || strings.Contains(bucketName, ".") {
return "", iodine.New(drivers.BucketNameInvalid{Bucket: bucketName}, nil)
}
if !drivers.IsValidObject(objectName) || strings.TrimSpace(objectName) == "" {
if !drivers.IsValidObjectName(objectName) || strings.TrimSpace(objectName) == "" {
return "", iodine.New(drivers.ObjectNameInvalid{Object: objectName}, nil)
}
if strings.TrimSpace(contentType) == "" {

View File

@ -184,9 +184,9 @@ func IsValidBucket(bucket string) bool {
return match
}
// IsValidObject - verify object name in accordance with
// IsValidObjectName - verify object name in accordance with
// - http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
func IsValidObject(object string) bool {
func IsValidObjectName(object string) bool {
if strings.TrimSpace(object) == "" {
return true
}

View File

@ -104,7 +104,7 @@ func (memory *memoryDriver) GetObject(w io.Writer, bucket string, object string)
memory.lock.RUnlock()
return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
}
if !drivers.IsValidObject(object) {
if !drivers.IsValidObjectName(object) {
memory.lock.RUnlock()
return 0, iodine.New(drivers.ObjectNameInvalid{Object: object}, nil)
}
@ -137,7 +137,7 @@ func (memory *memoryDriver) GetPartialObject(w io.Writer, bucket, object string,
if !drivers.IsValidBucket(bucket) {
return 0, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
}
if !drivers.IsValidObject(object) {
if !drivers.IsValidObjectName(object) {
return 0, iodine.New(drivers.ObjectNameInvalid{Object: object}, nil)
}
if _, err := memory.GetObject(&sourceBuffer, bucket, object); err != nil {
@ -217,7 +217,7 @@ func (memory *memoryDriver) createObject(bucket, key, contentType, expectedMD5Su
memory.lock.RUnlock()
return "", iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
}
if !drivers.IsValidObject(key) {
if !drivers.IsValidObjectName(key) {
memory.lock.RUnlock()
return "", iodine.New(drivers.ObjectNameInvalid{Object: key}, nil)
}
@ -408,7 +408,7 @@ func (memory *memoryDriver) ListObjects(bucket string, resources drivers.BucketR
if !drivers.IsValidBucket(bucket) {
return nil, drivers.BucketResourcesMetadata{IsTruncated: false}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
}
if !drivers.IsValidObject(resources.Prefix) {
if !drivers.IsValidObjectName(resources.Prefix) {
return nil, drivers.BucketResourcesMetadata{IsTruncated: false}, iodine.New(drivers.ObjectNameInvalid{Object: resources.Prefix}, nil)
}
if _, ok := memory.storedBuckets[bucket]; ok == false {
@ -467,7 +467,7 @@ func (memory *memoryDriver) GetObjectMetadata(bucket, key, prefix string) (drive
if !drivers.IsValidBucket(bucket) {
return drivers.ObjectMetadata{}, iodine.New(drivers.BucketNameInvalid{Bucket: bucket}, nil)
}
if !drivers.IsValidObject(key) || !drivers.IsValidObject(prefix) {
if !drivers.IsValidObjectName(key) || !drivers.IsValidObjectName(prefix) {
return drivers.ObjectMetadata{}, iodine.New(drivers.ObjectNameInvalid{Object: key}, nil)
}
if _, ok := memory.storedBuckets[bucket]; ok == false {