'Inspect the uploaded capsule\'s manifest and its contained files to ensure it is a valid
repository capsule.'

def validate_capsule(self, **kwd):

    capsule_dict = {}
    capsule_dict.update(kwd)
    encoded_file_path = capsule_dict.get('encoded_file_path', '')
    file_path = encoding_util.tool_shed_decode(encoded_file_path)
    export_info_file_path = os.path.join(file_path, 'export_info.xml')
    (export_info_tree, error_message) = xml_util.parse_xml(export_info_file_path)
    if error_message:
        capsule_dict['error_message'] = error_message
        capsule_dict['status'] = 'error'
        return capsule_dict
    manifest_file_path = os.path.join(file_path, 'manifest.xml')
    (repository_info_dicts, error_message) = self.get_repository_info_from_manifest(manifest_file_path)
    if error_message:
        capsule_dict['error_message'] = error_message
        capsule_dict['status'] = 'error'
        return capsule_dict
    (archives, error_message) = self.get_archives_from_manifest(manifest_file_path)
    if error_message:
        capsule_dict['error_message'] = error_message
        capsule_dict['status'] = 'error'
        return capsule_dict
    error_message = self.verify_archives_in_capsule(file_path, archives)
    if error_message:
        capsule_dict['error_message'] = error_message
        capsule_dict['status'] = 'error'
        return capsule_dict
    capsule_dict['status'] = 'ok'
    return capsule_dict
