# Path: oioswift/common/middleware/versioned_writes.py
# DELETE_MARKER_CONTENT_TYPE = vw.DELETE_MARKER_CONTENT_TYPE
# 
# Path: oioswift/utils.py
# def handle_oio_no_such_container(fnc):
#     """Catch NoSuchContainer errors and return '404 Not Found'"""
#     @wraps(fnc)
#     def _oio_no_such_container_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except NoSuchContainer:
#             return HTTPNotFound(request=req)
#     return _oio_no_such_container_wrapper
# 
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'
# 
# BUCKET_NAME_PROP = "sys.m2.bucket.name"
# 
# MULTIUPLOAD_SUFFIX = '+segments'


import json
from xml.etree.cElementTree import Element, SubElement, tostring
from swift.common.utils import public, Timestamp, \
    override_bytes_from_content_type
from swift.common.constraints import check_metadata
from swift.common import constraints
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from oioswift.common.middleware.versioned_writes import \
    DELETE_MARKER_CONTENT_TYPE
from swift.common.swob import Response, HTTPBadRequest, HTTPNotFound, \
    HTTPNoContent, HTTPConflict, HTTPPreconditionFailed, HTTPForbidden, \
    HTTPCreated
from swift.common.http import is_success, HTTP_ACCEPTED
from swift.common.request_helpers import is_sys_or_user_meta, get_param
from swift.proxy.controllers.container import ContainerController \
        as SwiftContainerController
from swift.proxy.controllers.base import clear_info_cache, \
    delay_denial, cors_validation, set_info_cache
from oio.common import exceptions
from oioswift.utils import \
    handle_oio_no_such_container, handle_oio_timeout, \
    handle_service_busy, REQID_HEADER, BUCKET_NAME_PROP, MULTIUPLOAD_SUFFIX
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.


try:
except ImportError:
    # Before Queens





class ContainerController(SwiftContainerController):

    pass_through_headers = ['x-container-read', 'x-container-write',
                            'x-container-sync-key', 'x-container-sync-to',
                            'x-versions-location']

    @handle_oio_no_such_container

# Path: oioswift/common/middleware/versioned_writes.py
# DELETE_MARKER_CONTENT_TYPE = vw.DELETE_MARKER_CONTENT_TYPE
# 
# Path: oioswift/utils.py
# def handle_oio_no_such_container(fnc):
#     """Catch NoSuchContainer errors and return '404 Not Found'"""
#     @wraps(fnc)
#     def _oio_no_such_container_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except NoSuchContainer:
#             return HTTPNotFound(request=req)
#     return _oio_no_such_container_wrapper
# 
# def handle_oio_timeout(fnc):
#     """
#     Catch DeadlineReached and OioTimeout errors
#     and return '503 Service Unavailable'.
#     """
#     @wraps(fnc)
#     def _oio_timeout_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (DeadlineReached, OioTimeout) as exc:
#             headers = dict()
#             # TODO(FVE): choose the value according to the timeout
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=str(exc))
#     return _oio_timeout_wrapper
# 
# def handle_service_busy(fnc):
#     @wraps(fnc)
#     def _service_busy_wrapper(self, req, *args, **kwargs):
#         try:
#             return fnc(self, req, *args, **kwargs)
#         except (ServiceBusy, ServiceUnavailable) as err:
#             headers = dict()
#             headers['Retry-After'] = '1'
#             return HTTPServiceUnavailable(request=req, headers=headers,
#                                           body=err.message)
#     return _service_busy_wrapper
# 
# REQID_HEADER = 'x-oio-req-id'
# 
# BUCKET_NAME_PROP = "sys.m2.bucket.name"
# 
# MULTIUPLOAD_SUFFIX = '+segments'


# Path: oioswift/proxy/controllers/container.py
import json
from xml.etree.cElementTree import Element, SubElement, tostring
from swift.common.utils import public, Timestamp, \
    override_bytes_from_content_type
from swift.common.constraints import check_metadata
from swift.common import constraints
    from swift.common.middleware.listing_formats import \
        get_listing_content_type
    from swift.common.request_helpers import get_listing_content_type
from oioswift.common.middleware.versioned_writes import \
    DELETE_MARKER_CONTENT_TYPE
from swift.common.swob import Response, HTTPBadRequest, HTTPNotFound, \
    HTTPNoContent, HTTPConflict, HTTPPreconditionFailed, HTTPForbidden, \
    HTTPCreated
from swift.common.http import is_success, HTTP_ACCEPTED
from swift.common.request_helpers import is_sys_or_user_meta, get_param
from swift.proxy.controllers.container import ContainerController \
        as SwiftContainerController
from swift.proxy.controllers.base import clear_info_cache, \
    delay_denial, cors_validation, set_info_cache
from oio.common import exceptions
from oioswift.utils import \
    handle_oio_no_such_container, handle_oio_timeout, \
    handle_service_busy, REQID_HEADER, BUCKET_NAME_PROP, MULTIUPLOAD_SUFFIX

#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.


try:
except ImportError:
    # Before Queens





class ContainerController(SwiftContainerController):

    pass_through_headers = ['x-container-read', 'x-container-write',
                            'x-container-sync-key', 'x-container-sync-to',
                            'x-versions-location']

    @handle_oio_no_such_container

    @handle_oio_timeout