def get_manifest(document_id, source, force_refresh, host): # Check if manifest exists has_manifest = models.manifest_exists(document_id, source) ## TODO: add last modified check if not has_manifest or force_refresh: if source == "object": (success, response) = get_huam(document_id, source) elif source == "gallery": (success, response) = get_huam_gallery(document_id, source) if not success: return (success, response, document_id, source) # This is actually the 404 HttpResponse, so return and end the function # Convert to shared canvas model if successful converted_json = huam.main(response, document_id, source, host) # Store to elasticsearch models.add_or_update_manifest(document_id, converted_json, source) return (success, converted_json, document_id, source) else: # return JSON from db json_doc = models.get_manifest(document_id, source) return (True, json.dumps(json_doc), document_id, source)
def get_manifest(document_id, source, force_refresh, host): # Check if manifest exists has_manifest = models.manifest_exists(document_id, source) ## TODO: add last modified check if not has_manifest or force_refresh: # If not, get MODS, METS, or HUAM JSON data_type = sources[source] if data_type == "mods": ## TODO: check image types?? (success, response) = get_mods(document_id, source) elif data_type == "mets": # check if mets object has jp2 images, only those will work in image server has_jp2 = mets_jp2_check(document_id) if not has_jp2: return (has_jp2, HttpResponse( "The document ID %s does not have JP2 images" % document_id, status=404), document_id, source) (success, response) = get_mets(document_id, source) elif data_type == "huam": (success, response) = get_huam(document_id, source) else: success = False response = HttpResponse("Invalid source type", status=404) if not success: return ( success, response, document_id, source ) # This is actually the 404 HttpResponse, so return and end the function # Convert to shared canvas model if successful if data_type == "mods": converted_json = mods.main(response, document_id, source, host) # check if this is, in fact, a PDS object masked as a hollis request # If so, get the manifest with the DRS METS ID and return that json_doc = json.loads(converted_json) if 'pds' in json_doc: id = json_doc['pds'] return get_manifest(id, 'drs', False, host) elif data_type == "mets": converted_json = mets.main(response, document_id, source, host) elif data_type == "huam": converted_json = huam.main(response, document_id, source, host) else: pass # Store to elasticsearch models.add_or_update_manifest(document_id, converted_json, source) # Return the documet_id and source in case this is a hollis record # that also has METS/PDS return (success, converted_json, document_id, source) else: # return JSON from db json_doc = models.get_manifest(document_id, source) return (True, json.dumps(json_doc), document_id, source)
def get_manifest(document_id, source, force_refresh, host, cookie=None): # Check if manifest exists has_manifest = models.manifest_exists(document_id, source) ## TODO: add last modified check if not has_manifest or force_refresh: # If not, get MODS, METS, or HUAM JSON data_type = sources[source] if data_type == "mods": ## TODO: check image types?? (success, response) = get_mods(document_id, source, cookie) elif data_type == "mets": (success, response) = get_mets(document_id, source, cookie) elif data_type == "huam": (success, response) = get_huam(document_id, source) else: success = False response = HttpResponse("Invalid source type", status=404) if not success: return (success, response, document_id, source) # This is actually the 404 HttpResponse, so return and end the function # Convert to shared canvas model if successful if data_type == "mods": converted_json = mods.main(response, document_id, source, host, cookie) # check if this is, in fact, a PDS object masked as a hollis request # If so, get the manifest with the DRS METS ID and return that json_doc = json.loads(converted_json) if 'pds' in json_doc: id = json_doc['pds'] return get_manifest(id, 'drs', False, host, cookie) elif data_type == "mets": converted_json = mets.main(response, document_id, source, host, cookie) elif data_type == "huam": converted_json = huam.main(response, document_id, source, host) else: pass # Store to elasticsearch models.add_or_update_manifest(document_id, converted_json, source) # Return the documet_id and source in case this is a hollis record # that also has METS/PDS return (success, converted_json, document_id, source) else: # return JSON from db json_doc = models.get_manifest(document_id, source) return (True, json.dumps(json_doc), document_id, source)