mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
Fix error messages returned by (Put)GetObjectLegalHold (#9013)
fiixing some minor discrepancies between aws s3 responses vs minio server
This commit is contained in:
parent
16a6e68d7b
commit
02a59a04d1
@ -151,6 +151,7 @@ const (
|
|||||||
ErrKeyTooLongError
|
ErrKeyTooLongError
|
||||||
ErrInvalidBucketObjectLockConfiguration
|
ErrInvalidBucketObjectLockConfiguration
|
||||||
ErrObjectLockConfigurationNotAllowed
|
ErrObjectLockConfigurationNotAllowed
|
||||||
|
ErrNoSuchObjectLockConfiguration
|
||||||
ErrObjectLocked
|
ErrObjectLocked
|
||||||
ErrInvalidRetentionDate
|
ErrInvalidRetentionDate
|
||||||
ErrPastObjectLockRetainDate
|
ErrPastObjectLockRetainDate
|
||||||
@ -761,6 +762,11 @@ var errorCodes = errorCodeMap{
|
|||||||
Description: "Object Lock configuration cannot be enabled on existing buckets.",
|
Description: "Object Lock configuration cannot be enabled on existing buckets.",
|
||||||
HTTPStatusCode: http.StatusConflict,
|
HTTPStatusCode: http.StatusConflict,
|
||||||
},
|
},
|
||||||
|
ErrNoSuchObjectLockConfiguration: {
|
||||||
|
Code: "NoSuchObjectLockConfiguration",
|
||||||
|
Description: "The specified object does not have a ObjectLock configuration",
|
||||||
|
HTTPStatusCode: http.StatusBadRequest,
|
||||||
|
},
|
||||||
ErrObjectLocked: {
|
ErrObjectLocked: {
|
||||||
Code: "InvalidRequest",
|
Code: "InvalidRequest",
|
||||||
Description: "Object is WORM protected and cannot be overwritten",
|
Description: "Object is WORM protected and cannot be overwritten",
|
||||||
|
@ -116,17 +116,17 @@ func registerAPIRouter(router *mux.Router, encryptionEnabled, allowSSEKMS bool)
|
|||||||
// SelectObjectContent
|
// SelectObjectContent
|
||||||
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(collectAPIStats("selectobjectcontent", httpTraceHdrs(api.SelectObjectContentHandler))).Queries("select", "").Queries("select-type", "2")
|
bucket.Methods(http.MethodPost).Path("/{object:.+}").HandlerFunc(collectAPIStats("selectobjectcontent", httpTraceHdrs(api.SelectObjectContentHandler))).Queries("select", "").Queries("select-type", "2")
|
||||||
// GetObjectRetention
|
// GetObjectRetention
|
||||||
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobjectretention", httpTraceHdrs(api.GetObjectRetentionHandler))).Queries("retention", "")
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobjectretention", httpTraceAll(api.GetObjectRetentionHandler))).Queries("retention", "")
|
||||||
// GetObjectLegalHold
|
// GetObjectLegalHold
|
||||||
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobjectlegalhold", httpTraceHdrs(api.GetObjectLegalHoldHandler))).Queries("legal-hold", "")
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobjectlegalhold", httpTraceAll(api.GetObjectLegalHoldHandler))).Queries("legal-hold", "")
|
||||||
// GetObject
|
// GetObject
|
||||||
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobject", httpTraceHdrs(api.GetObjectHandler)))
|
bucket.Methods(http.MethodGet).Path("/{object:.+}").HandlerFunc(collectAPIStats("getobject", httpTraceHdrs(api.GetObjectHandler)))
|
||||||
// CopyObject
|
// CopyObject
|
||||||
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(collectAPIStats("copyobject", httpTraceAll(api.CopyObjectHandler)))
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HeadersRegexp(xhttp.AmzCopySource, ".*?(\\/|%2F).*?").HandlerFunc(collectAPIStats("copyobject", httpTraceAll(api.CopyObjectHandler)))
|
||||||
// PutObjectRetention
|
// PutObjectRetention
|
||||||
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobjectretention", httpTraceHdrs(api.PutObjectRetentionHandler))).Queries("retention", "")
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobjectretention", httpTraceAll(api.PutObjectRetentionHandler))).Queries("retention", "")
|
||||||
// PutObjectLegalHold
|
// PutObjectLegalHold
|
||||||
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobjectlegalhold", httpTraceHdrs(api.PutObjectLegalHoldHandler))).Queries("legal-hold", "")
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobjectlegalhold", httpTraceAll(api.PutObjectLegalHoldHandler))).Queries("legal-hold", "")
|
||||||
|
|
||||||
// PutObject
|
// PutObject
|
||||||
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobject", httpTraceHdrs(api.PutObjectHandler)))
|
bucket.Methods(http.MethodPut).Path("/{object:.+}").HandlerFunc(collectAPIStats("putobject", httpTraceHdrs(api.PutObjectHandler)))
|
||||||
|
@ -2658,7 +2658,7 @@ func (api objectAPIHandlers) PutObjectLegalHoldHandler(w http.ResponseWriter, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSuccessNoContent(w)
|
writeSuccessResponseHeadersOnly(w)
|
||||||
// Notify object event.
|
// Notify object event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
EventName: event.ObjectCreatedPutLegalHold,
|
EventName: event.ObjectCreatedPutLegalHold,
|
||||||
@ -2718,8 +2718,15 @@ func (api objectAPIHandlers) GetObjectLegalHoldHandler(w http.ResponseWriter, r
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := globalBucketObjectLockConfig.Get(bucket); !ok {
|
||||||
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrInvalidBucketObjectLockConfiguration), r.URL, guessIsBrowserReq(r))
|
||||||
|
return
|
||||||
|
}
|
||||||
legalHold := objectlock.GetObjectLegalHoldMeta(objInfo.UserDefined)
|
legalHold := objectlock.GetObjectLegalHoldMeta(objInfo.UserDefined)
|
||||||
|
if legalHold.IsEmpty() {
|
||||||
|
writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrNoSuchObjectLockConfiguration), r.URL, guessIsBrowserReq(r))
|
||||||
|
return
|
||||||
|
}
|
||||||
writeSuccessResponseXML(w, encodeResponse(legalHold))
|
writeSuccessResponseXML(w, encodeResponse(legalHold))
|
||||||
// Notify object legal hold accessed via a GET request.
|
// Notify object legal hold accessed via a GET request.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
|
@ -475,6 +475,11 @@ type ObjectLegalHold struct {
|
|||||||
Status LegalHoldStatus `xml:"Status,omitempty"`
|
Status LegalHoldStatus `xml:"Status,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsEmpty returns true if struct is empty
|
||||||
|
func (l *ObjectLegalHold) IsEmpty() bool {
|
||||||
|
return l.Status != ON && l.Status != OFF
|
||||||
|
}
|
||||||
|
|
||||||
// ParseObjectLegalHold decodes the XML into ObjectLegalHold
|
// ParseObjectLegalHold decodes the XML into ObjectLegalHold
|
||||||
func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) {
|
func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error) {
|
||||||
if err = xml.NewDecoder(reader).Decode(&hold); err != nil {
|
if err = xml.NewDecoder(reader).Decode(&hold); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user