Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/common.py
Show First 20 Lines • Show All 733 Lines • ▼ Show 20 Lines | ) -> Receipt: | ||||
"Empty body request is not supported", | "Empty body request is not supported", | ||||
"Atom entry deposit is supposed to send for metadata. " | "Atom entry deposit is supposed to send for metadata. " | ||||
"If the body is empty, there is no metadata.", | "If the body is empty, there is no metadata.", | ||||
) | ) | ||||
create_origin = metadata.get("swh:deposit", {}).get("swh:create_origin") | create_origin = metadata.get("swh:deposit", {}).get("swh:create_origin") | ||||
if create_origin: | if create_origin: | ||||
origin_url = create_origin["swh:origin"]["@url"] | origin_url = create_origin["swh:origin"]["@url"] | ||||
if origin_url is not None: | |||||
provider_url = deposit.client.provider_url.rstrip("/") + "/" | |||||
if not origin_url.startswith(provider_url): | |||||
raise DepositError( | |||||
FORBIDDEN, | |||||
f"Cannot create origin {origin_url}, it must start with " | |||||
f"{provider_url}", | |||||
) | |||||
deposit.origin_url = origin_url | deposit.origin_url = origin_url | ||||
if "atom:external_identifier" in metadata: | if "atom:external_identifier" in metadata: | ||||
# Deprecated tag. | # Deprecated tag. | ||||
# When clients stopped using it, this should raise an error | # When clients stopped using it, this should raise an error | ||||
# unconditionally | # unconditionally | ||||
if deposit.origin_url: | if deposit.origin_url: | ||||
▲ Show 20 Lines • Show All 406 Lines • Show Last 20 Lines |