Example #1
0
 def GET(self):
     """
     List all available repositories
     """
     try:
         rm = rutils.get_repository_manager()
         inputs = web.input()
         if 'displayName' in inputs or 'genusTypeId' in inputs:
             querier = rm.get_repository_query()
             if 'displayName' in inputs:
                 if utilities.unescaped(inputs['displayName']):
                     querier.match_display_name(quote(inputs['displayName'],
                                                      safe='/ '),
                                                match=True)
                 else:
                     querier.match_display_name(inputs['displayName'],
                                                match=True)
             if 'genusTypeId' in inputs:
                 if utilities.unescaped(inputs['genusTypeId']):
                     querier.match_genus_type(quote(inputs['genusTypeId'],
                                                    safe='/ '),
                                              match=True)
                 else:
                     querier.match_genus_type(inputs['genusTypeId'],
                                              match=True)
             repositories = rm.get_repositories_by_query(querier)
         else:
             repositories = rm.repositories
         repositories = utilities.extract_items(repositories)
         return repositories
     except Exception as ex:
         utilities.handle_exceptions(ex)
Example #2
0
    def GET(self, log_id):
        try:
            logm = logutils.get_logging_manager()
            log = logm.get_log(utilities.clean_id(log_id))
            entries = log.get_log_entries()

            data = utilities.extract_items(entries)

            return data
        except Exception as ex:
            utilities.handle_exceptions(ex)
Example #3
0
 def GET(self):
     """
     List all available logs
     """
     try:
         logm = logutils.get_logging_manager()
         logs = logm.logs
         logs = utilities.extract_items(logs)
         return logs
     except Exception as ex:
         utilities.handle_exceptions(ex)
Example #4
0
 def GET(self):
     """
     List all available repositories
     """
     try:
         rm = rutils.get_repository_manager()
         repositories = rm.repositories
         repositories = utilities.extract_items(repositories)
         return repositories
     except Exception as ex:
         utilities.handle_exceptions(ex)
Example #5
0
    def GET(self, repository_id, asset_id):
        try:
            rm = rutils.get_repository_manager()
            repository = rm.get_repository(utilities.clean_id(repository_id))
            asset = repository.get_asset(utilities.clean_id(asset_id))
            data = utilities.extract_items(asset.get_asset_contents())

            if 'fullUrls' in self.data():
                data = json.dumps(
                    rutils.update_asset_map_with_content_url(
                        rm, asset.object_map)['assetContents'])

            return data
        except Exception as ex:
            utilities.handle_exceptions(ex)
Example #6
0
    def GET(self, repository_id=None):
        try:
            if repository_id is None:
                raise PermissionDenied
            rm = rutils.get_repository_manager()

            params = web.input()

            if 'allAssets' in params:
                als = rm.get_asset_lookup_session(proxy=rm._proxy)
                als.use_federated_repository_view()
                assets = als.get_assets()
            elif 'genusTypeId' in params:
                repository = rm.get_repository(
                    utilities.clean_id(repository_id))
                querier = repository.get_asset_query()
                if utilities.unescaped(params['genusTypeId']):
                    querier.match_genus_type(quote(params['genusTypeId'],
                                                   safe='/ '),
                                             match=True)
                else:
                    querier.match_genus_type(params['genusTypeId'], match=True)
                assets = repository.get_assets_by_query(querier)
            else:
                repository = rm.get_repository(
                    utilities.clean_id(repository_id))
                assets = repository.get_assets()
            data = utilities.extract_items(assets)

            # Update the source field with the displayName.text of the actual resource
            data = json.loads(data)
            for asset_map in data:
                resource_utils.update_asset_map_with_resource(asset_map)
            data = json.dumps(data)

            if 'fullUrls' in params:
                data = json.loads(data)
                updated_data = []
                for asset in data:
                    updated_data.append(
                        rutils.update_asset_map_with_content_url(rm, asset))

                data = json.dumps(updated_data)

            return data
        except Exception as ex:
            utilities.handle_exceptions(ex)