Skip to content

Commit

Permalink
Fixing the CEGA/LEGA interface
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdaz committed Oct 24, 2018
1 parent 80e2cee commit 34163f8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
22 changes: 11 additions & 11 deletions docs/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ CentralEGA gets notified of an inbox upload with:
{
"user": "john",
"filepath": "somedir/encrypted.file.c4gh",
"filesize": 123456,
"checksums": [{"type": "sha256", "checksum': "8ce5a6fd145f758c49a8e2e6028fb8654b5545f5eb27a051026f8f5e83426f76"}]
"file_path": "somedir/encrypted.file.c4gh",
"file_size": 123456,
"encrypted_checksums": [{"type": "sha256", "value": "8ce5a6fd145f758c49a8e2e6028fb8654b5545f5eb27a051026f8f5e83426f76"}]
}
CentralEGA could send:
Expand All @@ -169,7 +169,7 @@ CentralEGA could send:
{
"user": "john",
"filepath": "somedir/encrypted.file.c4gh",
"file_path": "somedir/encrypted.file.c4gh",
}
and LocalEGA could respond with:
Expand All @@ -178,9 +178,9 @@ and LocalEGA could respond with:
{
"user":"john",
"filepath":"somedir/encrypted.file.c4gh",
"checksums": [{"type": "sha256", "value": "e5b844cc57f57094ea4585e235f36c78c1cd222262bb89d53c94dcb4d6b3e55d"},
{"type": "md5", "value": "f1c9645dbc14efddc7d8a322685f26eb"}]
"file_path":"somedir/encrypted.file.c4gh",
"decrypted_checksums": [{"type": "sha256", "value": "e5b844cc57f57094ea4585e235f36c78c1cd222262bb89d53c94dcb4d6b3e55d"},
{"type": "md5", "value": "f1c9645dbc14efddc7d8a322685f26eb"}]
}
and the stable ID message would be:
Expand All @@ -189,9 +189,9 @@ and the stable ID message would be:
{
"user" : "john",
"stableId" : "EGAF00000000003",
"filePath" : "somedir/encrypted.file.c4gh",
"checksum" : { "type" : "sha256", "value" : "e5b844cc57f57094ea4585e235f36c78c1cd222262bb89d53c94dcb4d6b3e55d" }
"stable_id" : "EGAF00000000003",
"file_path" : "somedir/encrypted.file.c4gh",
"decrypted_checksums" : [{ "type" : "sha256", "value" : "e5b844cc57f57094ea4585e235f36c78c1cd222262bb89d53c94dcb4d6b3e55d" }]
}
In case of errors, Central EGA receives:
Expand All @@ -200,7 +200,7 @@ In case of errors, Central EGA receives:
{
"user": "john",
"filepath": "somedir/encrypted.file.c4gh",
"file_path": "somedir/encrypted.file.c4gh",
"reason": "Some user related error, like Decryption failed: wrong key signature"
}
Expand Down
8 changes: 4 additions & 4 deletions lega/finalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def work(data):

# Translating message from CentralEGA
_data = { # crash on purpose if KeyError
'filepath': data['filePath'],
'filepath': data['file_path'],
'user': data['user'],
'checksum': data['checksum']['value'],
'checksum_type': data['checksum']['type'],
'stable_id': data['stableId'],
'checksum': data['decrypted_checksums'][0]['value'],
'checksum_type': data['decrypted_checksums'][0]['type'],
'stable_id': data['stable_id'],
}

# Insert stable ID into database
Expand Down
2 changes: 1 addition & 1 deletion lega/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def work(fs, data):
org_msg = data.copy()
data['org_msg'] = org_msg

filepath = data['filepath']
filepath = data['file_path']
LOG.info(f"Processing {filepath}")

# Use user_id, and not elixir_id
Expand Down
6 changes: 3 additions & 3 deletions lega/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def send_message(self, username, filename):
else (filename, filename[len(inbox):]) # surely there is better!
LOG.debug("Filepath %s", filepath)
msg = { 'user': username,
'filepath': filename,
'filesize': os.stat(filepath).st_size
'file_path': filename,
'file_size': os.stat(filepath).st_size
}
c = calculate(filepath, 'sha256')
if c:
msg['checksums'] = [{'type': 'sha256', 'value': c}]
msg['encrypted_checksums'] = [{'type': 'sha256', 'value': c}]
# Sending
publish(msg, 'cega', 'files.inbox')

Expand Down
4 changes: 2 additions & 2 deletions lega/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def work(mover, data):
# Shape successful message
org_msg = data['org_msg']
org_msg.pop('file_id', None)
org_msg['checksums'] = [{ 'type': 'sha256', 'value': checksum },
{ 'type': 'md5', 'value': md5_digest }] # for stable id
org_msg['decrypted_checksums'] = [{ 'type': 'sha256', 'value': checksum },
{ 'type': 'md5', 'value': md5_digest }] # for stable id
LOG.debug(f"Reply message: {org_msg}")
return (org_msg, False)

Expand Down

0 comments on commit 34163f8

Please sign in to comment.