-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathculuploader.py
More file actions
52 lines (48 loc) · 1.93 KB
/
culuploader.py
File metadata and controls
52 lines (48 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""
Retrieve and disseminate files and metadata to
Cambridge University Library pilot collaboration DSpace
"""
from dspaceuploader import DSpaceUploader, MetadataProfile
from uploader import Location
class CULUploader(DSpaceUploader):
def __init__(self, work_id, export_url, client_url, version):
"""Set CUL-specific parameters and pass them to DSpaceUploader"""
user_name_string = 'cul_pilot_user'
user_pass_string = 'cul_pilot_pw'
service_document_iri = (
'https://api-thoth-arch.lib.cam.ac.uk/server/swordv2/'
'servicedocument'
)
collection_iri = (
'https://api-thoth-arch.lib.cam.ac.uk/server/swordv2/collection/'
'1811/2'
)
metadata_profile = MetadataProfile.JISC_ROUTER
super().__init__(
work_id,
export_url,
client_url,
version,
user_name_string,
user_pass_string,
service_document_iri,
collection_iri,
metadata_profile)
def upload_to_platform(self):
"""Perform standard upload then CUL-specific processing"""
(publication_id, pdf_upload_receipt,
deposit_receipt) = super().upload_to_platform()
# Return details of created upload to be entered as a Thoth Location
landing_page = deposit_receipt.alternate
# Receipt only contains SWORDv2 server URL - translate to frontend URL
bitstream_id = pdf_upload_receipt.location.partition(
'/bitstream/')[2].partition('/')[0]
if len(bitstream_id) > 0:
full_text_url = ('https://thoth-arch.lib.cam.ac.uk/bitstreams/{}/'
'download'.format(bitstream_id))
else:
full_text_url = None
location_platform = 'OTHER'
return [Location(publication_id, location_platform, landing_page,
full_text_url)]