Page MenuHomeSoftware Heritage

D265.id897.diff
No OneTemporary

D265.id897.diff

diff --git a/docs/index.rst b/docs/index.rst
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -9,6 +9,7 @@
getting-started.md
spec-api.md
+ metadata.md
spec-injection.md
dev-info.md
sys-info.md
diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py
--- a/swh/deposit/api/private/deposit_read.py
+++ b/swh/deposit/api/private/deposit_read.py
@@ -71,7 +71,7 @@
"""
ADDITIONAL_CONFIG = {
- 'extraction_dir': ('str', '/tmp/swh-deposit/archive/')
+ 'extraction_dir': ('str', '/tmp/swh-deposit/archive/'),
}
def __init__(self):
@@ -120,6 +120,28 @@
"""Class in charge of aggregating metadata on a deposit.
"""
+ ADDITIONAL_CONFIG = {
+ 'provider': ('dict', {
+ 'provider_name': '',
+ 'provider_type': 'deposit_client',
+ 'provider_url': '',
+ 'metadata': {
+ }
+ }),
+ 'tool': ('dict', {
+ 'tool_name': 'swh-deposit',
+ 'tool_version': '0.0.1',
+ 'tool_configuration': {
+ 'sword_version': '2'
+ }
+ })
+ }
+
+ def __init__(self):
+ super().__init__()
+ self.provider = self.config['provider']
+ self.tool = self.config['tool']
+
def _aggregate_metadata(self, deposit, metadata_requests):
"""Retrieve and aggregates metadata information.
@@ -150,8 +172,8 @@
# Read information metadata
data['origin'] = {
- 'type': deposit.collection.name,
- 'url': deposit.external_id,
+ 'type': 'deposit',
+ 'url': deposit.client.url + deposit.external_id,
}
# revision
@@ -163,6 +185,10 @@
'email': deposit.client.email,
}
+ # metadata provider
+ self.provider['provider_name'] = deposit.client.last_name
+ self.provider['provider_url'] = deposit.client.url
+
revision_type = 'tar'
revision_msg = '%s: Deposit %s in collection %s' % (
fullname, deposit.id, deposit.collection.name)
@@ -189,6 +215,12 @@
'branch': 'master'
}
+ data['origin_metadata'] = {
+ 'provider': self.provider,
+ 'tool': self.tool,
+ 'metadata': metadata
+ }
+
return data
def process_get(self, req, collection_name, deposit_id):
diff --git a/swh/deposit/injection/loader.py b/swh/deposit/injection/loader.py
--- a/swh/deposit/injection/loader.py
+++ b/swh/deposit/injection/loader.py
@@ -137,12 +137,31 @@
occurrence = metadata['occurrence']
self.client.update_deposit_status(deposit_update_url, 'injecting')
+
super().prepare(tar_path=archive,
origin=origin,
visit_date=visit_date,
revision=revision,
occurrences=[occurrence])
+ def store_metadata(self):
+ """Storing the origin_metadata during the load processus.
+
+ Fetching tool and metadata_provider from storage and adding the
+ metadata associated to the current origin.
+
+ """
+ origin_id = self.origin_id
+ visit_date = self.visit_date
+ provider = self.origin_metadata['provider']
+ tool = self.origin_metadata['tool']
+ metadata = self.origin_metadata['metadata']
+ try:
+ self.send_origin_metadata(self, origin_id, visit_date, provider,
+ tool, metadata)
+ except:
+ self.log.exception('Problem when storing origin_metadata')
+
def post_load(self, success=True):
"""Updating the deposit's status according to its loading status.
diff --git a/swh/deposit/migrations/0006_depositclient_url.py b/swh/deposit/migrations/0006_depositclient_url.py
new file mode 100644
--- /dev/null
+++ b/swh/deposit/migrations/0006_depositclient_url.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.7 on 2017-11-07 13:12
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('deposit', '0005_auto_20171019_1436'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='depositclient',
+ name='url',
+ field=models.TextField(default='https://hal.archives-ouvertes.fr/'),
+ preserve_default=False,
+ ),
+ ]
diff --git a/swh/deposit/models.py b/swh/deposit/models.py
--- a/swh/deposit/models.py
+++ b/swh/deposit/models.py
@@ -72,6 +72,7 @@
"""
collections = ArrayField(models.IntegerField(), null=True)
objects = UserManager()
+ url = models.TextField(null=False)
class Meta:
db_table = 'deposit_client'
diff --git a/swh/deposit/tests/__init__.py b/swh/deposit/tests/__init__.py
--- a/swh/deposit/tests/__init__.py
+++ b/swh/deposit/tests/__init__.py
@@ -12,6 +12,20 @@
TEST_CONFIG = {
'max_upload_size': 500,
'extraction_dir': '/tmp/swh-deposit/test/extraction-dir',
+ 'provider': {
+ 'provider_name': '',
+ 'provider_type': 'deposit_client',
+ 'provider_url': '',
+ 'metadata': {
+ }
+ },
+ 'tool': {
+ 'tool_name': 'swh-deposit',
+ 'tool_version': '0.0.1',
+ 'tool_configuration': {
+ 'sword_version': '2'
+ }
+ }
}
diff --git a/swh/deposit/tests/api/test_deposit_read_metadata.py b/swh/deposit/tests/api/test_deposit_read_metadata.py
--- a/swh/deposit/tests/api/test_deposit_read_metadata.py
+++ b/swh/deposit/tests/api/test_deposit_read_metadata.py
@@ -37,8 +37,24 @@
expected_meta = {
'origin': {
- 'url': 'some-external-id',
- 'type': 'hal'
+ 'url': 'https://hal.archives-ouvertes.fr/some-external-id',
+ 'type': 'deposit'
+ },
+ 'origin_metadata': {
+ 'metadata': {},
+ 'provider': {
+ 'provider_name': '',
+ 'provider_type': 'deposit_client',
+ 'provider_url': 'https://hal.archives-ouvertes.fr/',
+ 'metadata': {}
+ },
+ 'tool': {
+ 'tool_name': 'swh-deposit',
+ 'tool_version': '0.0.1',
+ 'tool_configuration': {
+ 'sword_version': '2'
+ }
+ }
},
'revision': {
'synthetic': True,
diff --git a/swh/deposit/tests/common.py b/swh/deposit/tests/common.py
--- a/swh/deposit/tests/common.py
+++ b/swh/deposit/tests/common.py
@@ -160,12 +160,14 @@
deposit_request_types[deposit_request_type] = drt
_name = 'hal'
+ _url = 'https://hal.archives-ouvertes.fr/'
# set collection up
_collection = DepositCollection(name=_name)
_collection.save()
# set user/client up
_client = DepositClient.objects.create_user(username=_name,
- password=_name)
+ password=_name,
+ url=_url)
_client.collections = [_collection.id]
_client.save()

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 18, 6:21 PM (5 d, 13 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216468

Event Timeline