'GET /api/folders/{encoded_folder_id}/contents
Displays a collection (list) of a folder\'s contents
(files and folders). Encoded folder ID is prepended
with \'F\' if it is a folder as opposed to a data set
which does not have it. Full path is provided in
response as a separate object providing data for
breadcrumb path building.
:param  folder_id: encoded ID of the folder which
contents should be library_dataset_dict
:type   folder_id: encoded string
:param kwd: keyword dictionary with other params
:type  kwd: dict
:returns: dictionary containing all items and metadata
:type:    dict
:raises: MalformedId, InconsistentDatabase, ObjectNotFound,
InternalServerError'

@expose_api_anonymous
def index(self, trans, folder_id, **kwd):

    is_admin = trans.user_is_admin()
    deleted = kwd.get('include_deleted', 'missing')
    current_user_roles = trans.get_current_user_roles()
    try:
        deleted = util.asbool(deleted)
    except ValueError:
        deleted = False
    decoded_folder_id = self.folder_manager.cut_and_decode(trans, folder_id)
    folder = self.folder_manager.get(trans, decoded_folder_id)
    if (trans.app.security_agent.can_access_library(current_user_roles, folder.parent_library) or is_admin):
        pass
    else:
        if trans.user:
            log.warning(('SECURITY:    User    (id:    %s)    without    proper    access    rights    is    trying    to    load    folder    with    ID    of    %s' % (trans.user.id, decoded_folder_id)))
        else:
            log.warning(('SECURITY:    Anonymous    user    is    trying    to    load    restricted    folder    with    ID    of    %s' % decoded_folder_id))
        raise exceptions.ObjectNotFound(('Folder    with    the    id    provided    (    %s    )    was    not    found' % str(folder_id)))
    folder_contents = []
    update_time = ''
    create_time = ''
    for content_item in self._load_folder_contents(trans, folder, deleted):
        return_item = {}
        encoded_id = trans.security.encode_id(content_item.id)
        update_time = content_item.update_time.strftime('%Y-%m-%d    %I:%M    %p')
        create_time = content_item.create_time.strftime('%Y-%m-%d    %I:%M    %p')
        if (content_item.api_type == 'folder'):
            encoded_id = ('F' + encoded_id)
            can_modify = (is_admin or (trans.user and trans.app.security_agent.can_modify_library_item(current_user_roles, folder)))
            can_manage = (is_admin or (trans.user and trans.app.security_agent.can_manage_library_item(current_user_roles, folder)))
            return_item.update(dict(can_modify=can_modify, can_manage=can_manage))
            if content_item.description:
                return_item.update(dict(description=content_item.description))
        if (content_item.api_type == 'file'):
            is_unrestricted = trans.app.security_agent.dataset_is_public(content_item.library_dataset_dataset_association.dataset)
            if (trans.user and trans.app.security_agent.dataset_is_private_to_user(trans, content_item)):
                is_private = True
            else:
                is_private = False
            can_manage = (is_admin or (trans.user and trans.app.security_agent.can_manage_dataset(current_user_roles, content_item.library_dataset_dataset_association.dataset)))
            nice_size = util.nice_size(int(content_item.library_dataset_dataset_association.get_size()))
            library_dataset_dict = content_item.to_dict()
            return_item.update(dict(file_ext=library_dataset_dict['file_ext'], date_uploaded=library_dataset_dict['date_uploaded'], is_unrestricted=is_unrestricted, is_private=is_private, can_manage=can_manage, file_size=nice_size))
            if content_item.library_dataset_dataset_association.message:
                return_item.update(dict(message=content_item.library_dataset_dataset_association.message))
        return_item.update(dict(id=encoded_id, type=content_item.api_type, name=content_item.name, update_time=update_time, create_time=create_time, deleted=content_item.deleted))
        folder_contents.append(return_item)
    full_path = self.build_path(trans, folder)[::(-1)]
    can_add_library_item = (is_admin or trans.app.security_agent.can_add_library_item(current_user_roles, folder))
    can_modify_folder = (is_admin or trans.app.security_agent.can_modify_library_item(current_user_roles, folder))
    parent_library_id = None
    if (folder.parent_library is not None):
        parent_library_id = trans.security.encode_id(folder.parent_library.id)
    metadata = dict(full_path=full_path, can_add_library_item=can_add_library_item, can_modify_folder=can_modify_folder, folder_name=folder.name, folder_description=folder.description, parent_library_id=parent_library_id)
    folder_container = dict(metadata=metadata, folder_contents=folder_contents)
    return folder_container
