def _es_listing(self, system, username, file_path, **kwargs): """Returns a "listing" dict constructed with the response from Elasticsearch. :param str system: system id :param str username: username which is requesting the listing. This is to check the permissions in the ES docs. :param str file_path: path to list :returns: A dict with information of the listed file and, when possible, a list of :class:`~designsafe.apps.api.data.agave.elasticsearch.documents.Object` objects dict in the key ``children`` :rtype: dict Notes: ----- This should not be called directly. See py:meth:`listing(file_id)` for more information. """ file_path = file_path or "/" res, listing = PublicObject.listing(system, file_path, **kwargs) default_pems = [ { "username": self.username, "permission": {"read": True, "write": False, "execute": True}, "recursive": True, } ] if file_path == "/": list_data = { "source": self.resource, "system": "nees.public", "id": "nees.public/", "type": "folder", "name": "", "path": "/", "ext": "", "size": None, "lastModified": None, "children": [o.to_dict(def_pems=default_pems, with_meta=True) for o in listing], "_trail": [], "_pems": default_pems, } else: root_listing = PublicObject.from_file_path(system, file_path) if root_listing: list_data = root_listing.to_dict(def_pems=default_pems) list_data["children"] = [o.to_dict(def_pems=default_pems) for o in listing] else: list_data = None return list_data
def search(self, **kwargs): res, s = PublicObject.search_query_with_projects(self.system_id, self.username, **kwargs) search_data = { "source": self.resource, "system": "nees.public", "id": "$search", "type": "folder", "name": "$SEARCH", "path": "", "ext": "", "size": None, "lastModified": None, "query": {"q": kwargs.get("q"), "fields": kwargs.get("fields", [])}, "children": [o.to_dict() for o in s if not o.path.startswith("%s/.Trash" % self.username)], "_trail": [], "_pems": [{"username": self.username, "permission": {"read": True}}], } return search_data
def search(self, **kwargs): res, s = PublicObject.search_query_with_projects( self.system_id, self.username, **kwargs) search_data = { 'source': self.resource, 'system': 'nees.public', 'id': '$search', 'type': 'folder', 'name': '$SEARCH', 'path': '', 'ext': '', 'size': None, 'lastModified': None, 'query': { 'q': kwargs.get('q'), 'fields': kwargs.get('fields', []) }, 'children': [ o.to_dict() for o in s if not o.path.startswith('%s/.Trash' % self.username) ], '_trail': [], '_pems': [{ 'username': self.username, 'permission': { 'read': True } }], } return search_data
def _es_listing(self, system, username, file_path, **kwargs): """Returns a "listing" dict constructed with the response from Elasticsearch. :param str system: system id :param str username: username which is requesting the listing. This is to check the permissions in the ES docs. :param str file_path: path to list :returns: A dict with information of the listed file and, when possible, a list of :class:`~designsafe.apps.api.data.agave.elasticsearch.documents.Object` objects dict in the key ``children`` :rtype: dict Notes: ----- This should not be called directly. See py:meth:`listing(file_id)` for more information. """ file_path = file_path or '/' res, listing = PublicObject.listing(system, file_path, **kwargs) default_pems = [{ 'username': self.username, 'permission': { 'read': True, 'write': False, 'execute': True }, 'recursive': True }] if file_path == '/': list_data = { 'source': self.resource, 'system': 'nees.public', 'id': 'nees.public/', 'type': 'folder', 'name': '', 'path': '/', 'ext': '', 'size': None, 'lastModified': None, 'children': [ o.to_dict(def_pems=default_pems, with_meta=True) for o in listing ], '_trail': [], '_pems': default_pems } else: root_listing = PublicObject.from_file_path(system, file_path) if root_listing: list_data = root_listing.to_dict(def_pems=default_pems) list_data['children'] = [ o.to_dict(def_pems=default_pems) for o in listing ] else: list_data = None return list_data